//
//  BasTableViewCell.m
//  KnowEveryThings
//
//  Created by lanou3g on 16/5/7.
//  Copyright © 2016年 王玲. All rights reserved.
//

#import "BasTableViewCell.h"

@implementation BasTableViewCell
//声明方法
//+ (instancetype)cellWithTableView:(UITableView *)tableView Model:(BasModel *)model IndexPath:(NSIndexPath *)indexPath {
//    NSString *modelName = NSStringFromClass([model class]);
//    
//    BasTableViewCell *baseCell = [tableView dequeueReusableCellWithIdentifier:modelName forIndexPath:indexPath];
//    
//    // 设置属性
//    [baseCell setmodel:model];
//    return baseCell;
//}

+ (instancetype)cellWithTableView:(UITableView *)tableView Model:(BasModel *)model IndexPath:(NSIndexPath *)indexPath identifier:(NSString *)identifier{
    NSString *modelName = NSStringFromClass([model class]);
    modelName = [modelName stringByAppendingString:@"Cell"];
    // 把WLModel拼接好Cell之后再转化为类
#warning tableView 从重用池里取cell 应该用这个
    Class cla = NSClassFromString(modelName);
    BasTableViewCell *bascell = [tableView dequeueReusableCellWithIdentifier:identifier];
//    BasTableViewCell *bascell = [tableView dequeueReusableCellWithIdentifier:identifier]

    if (bascell == nil) {
        bascell = [[[cla class] alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    
    //设置属性
    [bascell setmodel:model];
    return bascell;
}
- (void)setmodel:(BasModel *)model{
//    NSLog(@"不执行");
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
